package com.billsystem.mapper;

import com.billsystem.pojo.Record;
import com.billsystem.pojo.vo.RecordBc;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.sql.Date;
import java.util.List;

@Repository
@Mapper
public interface RecordMapper {
    //增加账单信息
    int addRecord(Record record);
    //增加账单信息到带有区块链部分的数据库，且无法删除
    int addRecordtob(RecordBc rbc);

    //根据id删除账单信息
    int deleteRecord(int id);
    //更新账单
    int updateRecord(Record record);

    //根据id查询账单
    Record queryRecord(int id);

    //根据用户id以及收入还是支出查看账单
    List<Record> queryRecordList(int uid, char incomeExpend);

    //根据用户id查询全部账单类型
    List<RecordBc> queryAllRecord(int uid);
    //查询今日的账单
    List<Record> queryRecordToday(Record record);
    //查询本月的账单
    List<Record> queryRecordThisMonth(@Param("start") Date start, @Param("end") Date end, @Param("uid") int uid, @Param("incomeExpend") char incomeExpend);
    //查询消费种类所消费的次数
    int queryCountOfCategory(@Param("cid") int cid,@Param("uid") int uid);
    //查询消费消费种类所涉及的金额
    double queryCountOfSpend(@Param("cid") int cid,@Param("uid") int uid);
    //查询消费种类的id
    List<Integer> queryRecordByCategory(int cid);

    //查询blockchain中的id数目
    int selectNumber();
}
